# -*- coding: utf-8 -*-
# 学习：https://cloud.tencent.com/developer/article/2295354
import os.path

from loguru import logger

logger.add(os.path.join(os.getcwd(), '..', 'logs', f'{os.path.splitext(os.path.basename(__file__))[0]}.log'),
           rotation="10 MB", retention="10 days")


def my_fun(x, y):
    try:
        return x / y
    except ZeroDivisionError:
        logger.exception("报错。。。。")


@logger.catch
def test_fun(x, y):
    return x / y


if __name__ == '__main__':
    logger.info("测试日志...........")
    logger.debug("测试日志...........")
    logger.warning("测试日志...........")
    logger.error("测试日志...........")
    my_fun(1232, 2)
    test_fun(4, 0)
